package cn.enited.devtools.apiaggregator.repo;

import cn.enited.devtools.apiaggregator.entity.BaseEntity;
import cn.enited.devtools.apiaggregator.exception.BizException;
import org.springframework.data.domain.Page;
import org.springframework.data.mongodb.core.query.Query;

import java.util.Collection;
import java.util.List;
import java.util.Optional;

public interface BaseRepository<T extends BaseEntity> {

    Class<T> getEntityType();

    Optional<T> getByBizId(Long bizId);

    List<T> findAll(Query query);

    Optional<T> findOne(Query query);

    boolean exists(Long bizId);

    boolean exists(Query query);

    long count(Query query);

    Page<T> findPage(Query query, int pageNumber, int pageSize);

    Page<T> findPage(Query query, int pageNumber);

    void save(T entity) throws BizException;

    void update(T entity) throws BizException;

    void delete(Long bizId) throws BizException;
}
